returns=[12 8 50]; STDs=[24.559 32.009 113.92]; correlations=[1 0 0;0 1 0;0 0 1]; covariances = corr2cov(STDs , correlations); variances = corr2cov(STDs , correlations); portopt(returns , covariances , 20); [PortRisk, PortReturn, PortWts] = frontcon(returns,covariances,20); [PortRisk, PortReturn, PortWts]
警告: In a future release, portopt will undergo a change to solve only the default portfolio problem for long-only fully-invested portfolios. To solve more general problems, use the Portfolio object. See the release notes for details, including examples to make the conversion. 警告: In a future release, frontcon will be removed. Use the Portfolio object instead. See the release notes for details, including examples to make the conversion. 警告: In a future release, portopt will no longer accept ConSet or varargin arguments. 'It will only solve the portfolio problem for long-only fully-invested portfolios. To solve more general problems, use the Portfolio object. See the release notes for details, including examples to make the conversion. ans = 19.2058 11.6400 0.6116 0.3600 0.0284 20.0269 13.6590 0.6211 0.3033 0.0756 22.3096 15.6779 0.6306 0.2466 0.1227 25.6669 17.6968 0.6401 0.1900 0.1699 29.7370 19.7158 0.6497 0.1333 0.2171 34.2669 21.7347 0.6592 0.0766 0.2642 39.0970 23.7537 0.6687 0.0199 0.3114 44.1582 25.7726 0.6376 0 0.3624 49.4695 27.7916 0.5844 0 0.4156 54.9653 29.8105 0.5313 0 0.4687 60.5955 31.8295 0.4782 0 0.5218 66.3259 33.8484 0.4250 0 0.5750 72.1325 35.8674 0.3719 0 0.6281 77.9984 37.8863 0.3188 0 0.6812 83.9111 39.9053 0.2657 0 0.7343 89.8613 41.9242 0.2125 0 0.7875 95.8422 43.9432 0.1594 0 0.8406 101.8483 45.9621 0.1063 0 0.8937 107.8753 47.9811 0.0531 0 0.9469 113.9200 50.0000 0 0 1.0000